home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 June / PCWorld_2007-06_cd.bin / zabezpeceni / spyeraser / spyeraser.exe / {app} / SpyEraser.dll / 2110 / BASICDIVOBJECT.JS < prev    next >
Text File  |  2007-04-23  |  5KB  |  124 lines

  1. /*
  2. Script by RoBorg
  3. RoBorg@RoBorg.co.uk
  4. http://www.roborg.co.uk
  5. Do NOT remove this message!
  6. */
  7.  
  8. /*
  9. Usage:
  10. myDivObj = new divObject('myDivId', 'document.');
  11. onload="activateDivs()"
  12. myDiv.write('text')
  13. myDiv.setBgColour('#xxxxxx')
  14. myDiv.hide()
  15. myDiv.show()
  16. myDiv.swapImage('imgName', 'src')
  17. myDiv.captureEvents('event', 'action')
  18. myDiv.moveTo(x, y)
  19. myDiv.moveby(x, y)
  20. myDiv.resizeTo(x, y)
  21. myDiv.resizeBy(x, y)
  22. myDiv.clip(top, left, width, height)
  23. */
  24.  
  25. divObjectArray = new Array();
  26.  
  27. function activateDivs()
  28. {
  29. for(var x=0; x<divObjectArray.length; x++)
  30. divObjectArray[x].activate();
  31. }
  32.  
  33. function divObject(divName, parent)
  34. {
  35. if(!browserVars.type.getById)
  36. {
  37. this.div = parent + divName;
  38. this.baseDiv = parent + divName;
  39. this.divName = parent + divName;
  40. this.write = new Function("text", "this.div.document.open(); this.div.document.write(text); this.div.document.close(); this.width = this.div.clip.width; this.height = this.div.clip.height;");
  41. this.setBgColour = new Function("colour", "this.div.bgColor = colour;");
  42. this.setBgImage = new Function("src", "this.div.bgImage = 'url(' + src + ')';");
  43. this.hide = new Function("this.div.visibility = 'hide';");
  44. this.show = new Function("this.div.visibility = 'inherit';");
  45. this.setSize = new Function("left", "top", "width", "height", "this.div.clip.left = left; this.div.clip.top = top; this.div.clip.width = width; this.div.clip.height = height; this.div.width = width; this.div.height = height; this.div.clip.height = height; this.width = width; this.height = height;");
  46. this.swapImage = new Function("image", "src", "this.div.document.images[image].src = src");
  47. this.getImageSrc = new Function("image", "return this.div.document.images[image].src");
  48. }
  49. else
  50. {
  51. this.div = divName;
  52. this.baseDiv = divName;
  53. this.divName = divName;
  54. this.write = new Function("text", "document.getElementById('" + divName + "').innerHTML = text; this.width = this.baseDiv.offsetWidth; this.height = this.baseDiv.offsetHeight;");
  55. this.setBgColour = new Function("colour", "this.div.backgroundColor = colour;");
  56. this.setBgImage = new Function("src", "this.div.backgroundImage = 'url(' + src + ')';");
  57. this.hide = new Function("this.div.visibility = 'hidden';");
  58. this.show = new Function("this.div.visibility = 'inherit';");
  59. this.setSize = new Function("left", "top", "width", "height", "setWidthAndHeight", "this.div.clip = 'rect(' + top + ',' + (left+width) + ',' + (top+height) + ',' + left + ')'; if(setWidthAndHeight != false){this.div.width = width; this.div.height = height; this.width = width; this.height = height;}");
  60. this.swapImage = new Function("image", "src", "document.images[image].src = src");
  61. this.getImageSrc = new Function("image", "return document.images[image].src");
  62. }
  63. this.activate = activateDiv;
  64. this.setXY = new Function("x", "y", "this.div.left = x; this.div.top = y;");
  65. this.captureEvents = captureDivEvents;
  66. this.idNo = divObjectArray.length;
  67. divObjectArray[divObjectArray.length] = this;
  68.  
  69. this.width = 0;
  70. this.height = 0;
  71. this.originalWidth = 0;
  72. this.originalHeight = 0;
  73. this.left = 0;
  74. this.top = 0;
  75. this.clipLeft = 0;
  76. this.clipTop = 0;
  77.  
  78. this.moveTo = new Function("x", "y", "this.left=x; this.top=y; this.setXY(x, y)");
  79. this.moveBy = new Function("x", "y", "this.left+=x; this.top+=y; this.setXY(this.left, this.top)");
  80. this.resizeTo = new Function("x", "y", "this.width=x; this.height=y; this.setSize(this.clipLeft, this.clipTop, this.width, this.height)");
  81. this.resizeBy = new Function("x", "y", "this.width+=x; this.height+=y; this.setSize(this.clipLeft, this.clipTop, this.width, this.height)");
  82. this.clip = new Function("left", "top", "width", "height", "setWidthAndHeight", "this.clipLeft=left; this.clipTop=top; this.clipWidth=width; this.clipHeight=height; this.setSize(left, top, width, height, setWidthAndHeight);");
  83. this.setZIndex = new Function("z", "this.div.zIndex=z;");
  84. }
  85.  
  86.  
  87. function activateDiv()
  88. {
  89. if(typeof(this.div) != 'string') return;
  90.  
  91. if(!browserVars.type.getById)
  92. {
  93. this.baseDiv = eval(this.div);
  94. this.div = this.baseDiv
  95.  
  96. this.width = this.div.clip.width;
  97. this.height = this.div.clip.height;
  98. this.left = this.div.left;
  99. this.top = this.div.top;
  100. }
  101. else
  102. {
  103. this.baseDiv = document.getElementById(this.div);
  104. this.div = this.baseDiv.style;
  105.  
  106. this.width = this.baseDiv.offsetWidth;
  107. this.height = this.baseDiv.offsetHeight;
  108. this.left = this.baseDiv.offsetLeft;
  109. this.top = this.baseDiv.offsetTop;
  110. }
  111.  
  112. this.clipWidth = this.width;
  113. this.clipHeight = this.height;
  114. this.originalWidth = this.width;
  115. this.originalHeight = this.height;
  116. }
  117.  
  118.  
  119. function captureDivEvents(eventName, action)
  120. {
  121. if(!browserVars.type.getById)
  122. eval('this.div.captureEvents(Event.' + eventName.toUpperCase() + ')');
  123. eval('this.baseDiv.on' + eventName + ' = new Function("e", "' + action + '")');
  124. }